package com.octopus.optiworks.action;

import java.util.Map;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
import org.springframework.stereotype.Component;

@Component
public class Step100_1Action implements ExternalActivityBehaviour {

	private static final long serialVersionUID = 1L;
	
	private static Log log = LogFactory.getLog(Step100_1Action.class);

	public void signal(ActivityExecution execution, String arg1, Map<String, ?> arg2)
			throws Exception {
		log.debug(">>>>>>>>Step100_1Action signal()");
		execution.setVariables(arg2);
		execution.take(arg1);
		log.debug("<<<<<<<<Step100_1Action signal()");
	}

	@SuppressWarnings("unchecked")
	public void execute(ActivityExecution execute) throws Exception {
		log.debug(">>>>>>>>Step100_1Action execute()");
		Set<String> scope = (Set<String>)execute.getProcessInstance().getVariable("scope");
		if(scope.contains(StepActionUtil.STEP_100_1))
			execute.waitForSignal();
		log.debug("<<<<<<<<Step100_1Action execute()");
	}

}
